﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GUI.Base;
using GUI.Controllers;
using BusinessObjects.Objects;

namespace GUI.Forms
{
	internal sealed partial class OrganisationForm : BaseForm
	{
		
		#region Members

		private OrganisationController controller;

		#endregion

		#region Construction

		public OrganisationForm(OrganisationController controller)
		{
			this.controller = controller;
			InitializeComponent();
			SetFieldValues();
			InitFields();
		}

		#endregion

		#region Properties

		public OrganisationObject MyModel
		{
			get;
			set;
		}

		#endregion

		#region Methods


		public override void SaveFormToModel()
		{

			this.MyModel.OrgName = this.txtOrgName.Text;
			this.MyModel.Prefix = this.txtPrefix.Text;
			this.MyModel.Suchbegriff = this.txtSuchbegriff.Text;

		}

		public void SetFieldValues()
		{
			this.organisationBindingSource.DataSource = MyModel;
			
		}

		private void InitFields()
		{
			this.txtOrgName.TextChanged += new EventHandler(SetFormDirty);
			this.txtPrefix.TextChanged += new EventHandler(SetFormDirty);
			this.txtSuchbegriff.TextChanged += new EventHandler(SetFormDirty);
		}


		private void OrganisationForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			base.FormClosingEvent(sender, e, controller);
		}

		public bool Dirty
		{
			get { return base.IsDirty; }
			set { base.IsDirty = value; }
		}

		private void OrganisationForm_Load(object sender, EventArgs e)
		{
			Dirty = false;
		}

		#endregion
	}
}
